/* eslint-disable no-return-await */
import BaseService from './base_service'
export default class TransFormService extends BaseService {
  async spuCodeList () {
    return await this.axios.get('/transform/spuCodeList')
  }

  async actionDispatchConfig ({ action = 'remove', transFormConfig }) {
    return await this.axios.post(`/transform/actionDispatchConfig/${action}`, transFormConfig)
  }

  async actionProductDispatchConfig ({ id, transformStatus }) {
    return await this.axios.get(`/transform/spu/updateStatus/${id}?transformStatus=${transformStatus}`)
  }

  async addProduct (transFormProduct) {
    transFormProduct.fromBeLocation = transFormProduct.fromBeLocation.reduce((a, b) => `${a},${b}`)
    return await this.axios.post(`/transform/spu/addProduct`, transFormProduct)
  }

  async dispatchConfigList (param = {
    spuCode: null,
    fromProductCode: null,
    transformName: null,
    transformStatus: null,
    fromBeLocation: null,
    page: 0,
    size: 5
  }) {
    return await this.axios.get('/transform/dispatchList', {
      params: param
    })
  }

  async dispatchSpuConfigList (param = {
    spuCode: null,
    fromProductCode: null,
    transformName: null,
    fromBeLocation: null,
    page: 0,
    size: 5
  }) {
    return await this.axios.get('/transform/spu/dispatchList', {
      params: param
    })
  }

  async configDetail (id) {
    return await this.axios.get(`/transform/${id}`)
  }

  async loadProcessLog (param = {
    configId: null,
    page: 0,
    size: 5
  }) {
    return await this.axios.get('/transform/logForDispatch', {
      params: param
    })
  }
  async loadOrderDataByLogId (param = {
    transFormLogId: null,
    page: 0,
    size: 6
  }) {
    return await this.axios.get('/transform/orderList', {
      params: param
    })
  }

  async spuDelete (id) {
    return await this.axios.delete(`/transform/spu/${id}`)
  }

  async skuDelete (id) {
    return await this.axios.delete(`/transform/sku/${id}`)
  }
  async distchChannel () {
    return await this.axios.get('/transform/distchchannelList')
  }
}
